package android.slc.icr.core.entity;

import java.io.Serializable;
import java.util.Objects;

public class IcrUserInfo implements Serializable {
    public static final int ACTOR_STATUS_NONE = 0;
    public static final int ACTOR_STATUS_AGREE = 1;
    public static final int ACTOR_STATUS_REFUSE = 2;
    private String relate;//消息标记
    private String relateId;
    private String userId;
    private String userName;
    private String timeId;
    private boolean actor;
    private boolean create;
    private int actorStatus;
    private String extra;

    public IcrUserInfo() {
    }

    public IcrUserInfo(String relate, String relateId, String userId, String userName, String timeId, boolean actor,
                       boolean create, int actorStatus, String extra) {
        this.relate = relate;
        this.relateId = relateId;
        this.userId = userId;
        this.userName = userName;
        this.timeId = timeId;
        this.actor = actor;
        this.create = create;
        this.actorStatus = actorStatus;
        this.extra = extra;
    }

    public IcrUserInfo(String userId) {
        this.userId = userId;
    }

    public String getRelate() {
        return relate;
    }

    public void setRelate(String relate) {
        this.relate = relate;
    }

    public String getRelateId() {
        return relateId;
    }

    public void setRelateId(String relateId) {
        this.relateId = relateId;
    }

    public String getUserId() {
        return userId;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public void setTimeId(String timeId) {
        this.timeId = timeId;
    }

    public String getTimeId() {
        return timeId;
    }

    public boolean isActor() {
        return actor;
    }

    public void setActor(boolean actor) {
        this.actor = actor;
    }

    public boolean isCreate() {
        return create;
    }

    public void setCreate(boolean create) {
        this.create = create;
    }

    public int getActorStatus() {
        return actorStatus;
    }

    public void setActorStatus(int actorStatus) {
        this.actorStatus = actorStatus;
    }

    public void setExtra(String extra) {
        this.extra = extra;
    }

    public Object getExtra() {
        return extra;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof IcrUserInfo)) return false;
        IcrUserInfo that = (IcrUserInfo) o;
        return Objects.equals(relate, that.relate) && Objects.equals(relateId, that.relateId) && Objects.equals(userId, that.userId);
    }

    @Override
    public int hashCode() {
        return Objects.hash(relate, relateId, userId);
    }

    public boolean selfTest() {
        return relateId != null && relateId.length() > 0 &&
                relate != null && relate.length() > 0 &&
                userId != null && userId.length() > 0;
    }

    public Builder toBuilder() {
        return newBuilder().setRelate(this.getRelate())
                .setRelateId(this.getRelateId())
                .setUserId(this.getUserId())
                .setUserName(this.getUserName())
                .setTimeId(this.getTimeId())
                .setActor(this.isActor())
                .setCreate(this.isCreate())
                .setActorStatus(this.getActorStatus());
    }

    public static Builder newBuilder() {
        return new Builder();
    }

    public static class Builder {
        private String relate;//消息标记
        private String relateId;
        private String userId;
        private String userName;
        private String timeId;
        private boolean actor;
        private boolean create;
        private int actorStatus = ACTOR_STATUS_NONE;
        private String extra;

        public Builder() {

        }

        public Builder setRelate(String relate) {
            this.relate = relate;
            return this;
        }

        public Builder setRelateId(String relateId) {
            this.relateId = relateId;
            return this;
        }

        public Builder setUserId(String userId) {
            this.userId = userId;
            return this;
        }

        public Builder setUserName(String userName) {
            this.userName = userName;
            return this;
        }

        public Builder setTimeId(String timeId) {
            this.timeId = timeId;
            return this;
        }

        public Builder setActor(boolean actor) {
            this.actor = actor;
            return this;
        }

        public Builder setCreate(boolean create) {
            this.create = create;
            return this;
        }

        public Builder setActorStatus(int actorStatus) {
            this.actorStatus = actorStatus;
            return this;
        }

        public Builder setExtra(String extra) {
            this.extra = extra;
            return this;
        }

        public IcrUserInfo build() {
            return new IcrUserInfo(relate, relateId, userId, userName, timeId, actor, create, actorStatus, extra);
        }
    }
}
